package com.example.a1.fannong.core.app;

import android.support.compat.BuildConfig;
import android.util.Log;

/**
 * 日志打印
 *
 * @author nsh
 */
public class Logger {

    private String tag;

    public Logger(String tag) {
        super();
        this.tag = tag;
    }

    public Logger(Object object) {
        this(object.getClass());
    }

    public Logger(Class<?> clazz) {
        this(clazz.getSimpleName());
    }

    public void d(String format, Object... args) {
        if(BuildConfig.DEBUG)
            Log.d(tag, String.format(format, args));
    }

    public void e(String format, Object... args) {
        if(BuildConfig.DEBUG)
            Log.e(tag, String.format(format, args));
    }

    public void e(Throwable throwable, String format, Object... args) {
        if(BuildConfig.DEBUG)
            Log.e(tag, String.format(format, args), throwable);
    }

    public void i(String format, Object... args) {
        if(BuildConfig.DEBUG)
            Log.i(tag, String.format(format, args));
    }

    public void w(String format, Object... args) {
        if(BuildConfig.DEBUG)
            Log.w(tag, String.format(format, args));
    }
}
